package one.stand.controller;

import one.stand.model.ResultModel;
import one.stand.request.*;
import one.stand.response.OrdersResponse;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 订单信息
 * @author Administrator
 */
@RestController
@RequestMapping("/orders")
public class OrdersController extends BaseController {

    /**
     * 查询我的购物车
     */
    @PostMapping("/selectShopcart")
    public ResultModel selectShopcart(@RequestBody ShopcartRequest shopcartRequest) {
        return ordersService.selectShopcart(shopcartRequest);
    }

    /**
     * 保存商品到购物车
     */
    @PostMapping("/addShopcart")
    public ResultModel addShopcart(@RequestBody ShopcartRequest shopcartRequest) {
        return ordersService.addShopcart(shopcartRequest);
    }

    /**
     * 删除购物车商品
     */
    @PostMapping("/delShopcart")
    public ResultModel delShopcart(@RequestBody ShopcartRequest shopcartRequest) {
        return ordersService.delShopcart(shopcartRequest);
    }

    /**
     * 修改购物车商品数量
     */
    @PostMapping("/updShopcartNum")
    public ResultModel updShopcartNum(@RequestBody ShopcartRequest shopcartRequest) {
        return ordersService.updShopcartNum(shopcartRequest);
    }

    /**
     * 商品直接下单
     */
    @PostMapping("/directOrder")
    public ResultModel directOrder(@RequestBody OrderinfoRequest orderinfoRequest) {
        return ordersService.directOrder(orderinfoRequest);
    }

    /**
     * 购物车下单
     */
    @PostMapping("/shopcartOrder")
    public ResultModel<String> shopcartOrder(@RequestBody ShopcartRequest shopcartRequest) {
        return ordersService.shopcartOrder(shopcartRequest);
    }

    /**
     * 查询用户订单信息
     */
    @PostMapping("/getOrderList")
    public ResultModel<List<OrdersResponse>> getOrderList(@RequestBody OrdersRequest request) {
        return ordersService.getOrderList(request);
    }

    /**
     * 查询用户订单数量
     */
    @PostMapping("/getOrderListCount")
    public ResultModel<List<Map<String, Object>>> getOrderListCount(@RequestBody OrdersRequest request) {
        return ordersService.getOrderListCount(request);
    }

    /**
     * 去支付（旧）
     * @param request
     * @return
     */
    @PostMapping("/goPay")
    public ResultModel<Map<String, String>> goPay(@RequestBody OrdersRequest request) {
        return ordersService.goPay(request);
    }

    /**
     * 去支付（新-3.2版本迭代）
     * @param request
     * @return
     */
    @PostMapping("/goPayNew")
    public ResultModel<Map<String, String>> goPayNew(@RequestBody OrdersRequest request) {
        return ordersService.goPayNew(request);
    }

    /**
     * 去支付（下单未支付后再次支付）
     * @param request
     * @return
     */
    @PostMapping("/goTwoPay")
    public ResultModel<Map<String, String>> goTwoPay(@RequestBody OrdersRequest request) {
        return ordersService.goTwoPay(request);
    }

    /**
     * 订单支付（回调）
     */
    @PostMapping("/paymentOrders")
    public String paymentOrders(@RequestParam(value="request") String request) {
        return ordersService.paymentOrders(request);
    }

    /**
     * 用户提交退款申请
     */
    @PostMapping("/refundOrder")
    public ResultModel refundOrder(@RequestBody OrdersRequest ordersRequest) {
        return ordersService.refundOrder(ordersRequest);
    }

    /**
     * 用户撤销退款申请
     */
    @PostMapping("/backRefundState")
    public ResultModel backRefundState(@RequestBody OrdersRequest ordersRequest) {
        return ordersService.backRefundState(ordersRequest);
    }

    /**
     * 修改订单状态
     */
    @PostMapping("/updateOrderState")
    public ResultModel updateOrderState(@RequestBody OrdersRequest request) {
        return ordersService.updateOrderState(request);
    }

    /**
     * 提醒发货
     */
    @PostMapping("/doReminder")
    public ResultModel doReminder(@RequestBody OrdersRequest request) {
        return ordersService.doReminder(request);
    }

    /**
     * 再来一单
     */
    @PostMapping("/anotherOrder")
    public ResultModel anotherOrder(@RequestBody OrdersRequest request) {
        return ordersService.anotherOrder(request);
    }

    /**
     * 购物车添加收藏
     */
    @PostMapping("/shopAddCollection")
    public ResultModel shopAddCollection(@RequestBody CollectionRequest request) {
        return ordersService.shopAddCollection(request);
    }

    /**
     * 下单时订单详情
     */
    @PostMapping("/getOrderInfo")
    public ResultModel<List<OrdersResponse>> getOrderInfo(@RequestBody OrdersRequest request) {
        return ordersService.getOrderInfo(request);
    }

    /**
     * 待付款时订单详情
     */
    @PostMapping("/getPayOrderInfo")
    public ResultModel<List<OrdersResponse>> getPayOrderInfo(@RequestBody OrdersRequest request) {
        return ordersService.getPayOrderInfo(request);
    }

    /**
     * 开团/参团
     */
    @PostMapping("/openOrJoinAssemble")
    public ResultModel<Integer> openOrJoinAssemble(@RequestBody AssembleRequest request) {
        return ordersService.openOrJoinAssemble(request);
    }
}
